{% include "iframe_header" %}


<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="" lay-filter="searchForm">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">交易对</label>
                            <div class="layui-input-inline">
                                <select name="symbol" lay-verify="required" lay-reqtext="不能为空">
                                    <option value="">请选择</option>
                                    {% range $k,$v := .all_symbols %}
                                    <option value="{%$v.Symbol%}">{%$v.Name%}/{%$v.Symbol%}</option>
                                    {%end%}
                                </select>
                            </div>
                        </div>
                        
                        <div class="layui-inline">
                            <label class="layui-form-label">卖方</label>
                            <div class="layui-input-inline">
                                <input type="text" name="ask_uid" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">卖方订单</label>
                            <div class="layui-input-inline">
                                <input type="text" name="ask" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">买方</label>
                            <div class="layui-input-inline">
                                <input type="text" name="bid_uid" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        

                        <div class="layui-inline">
                            <label class="layui-form-label">买方订单</label>
                            <div class="layui-input-inline">
                                <input type="text" name="bid" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        
                        
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                            <button type="reset" class="layui-btn layui-btn-primary">清空</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <script type="text/html" id="toolbarDemo">
            
        </script>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            
        </script>

    </div>
</div>


<script>
    layui.use(['form', 'table','element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

            table.render({
            elem: '#currentTableId',
            url: '/admin/user/trade/history?api=1',
            //toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            where: {"searchParams": {% .search | json %}},
            cols: [[
                {type: "checkbox", width: 30},
                {field: 'trade_id', title: '成交ID', width:230},
                {field: 'ask', title: '卖方订单', width:200},
                {field: 'bid', title: '买方订单', width:200},
                {field: 'price', title: '成交价格'},
                {field: 'quantity', title: '数量'},
                {field: 'amount', title: '成交金额'},
                {field: 'ask_fee_rate', title: '卖方费率'},
                {field: 'ask_fee', title: '卖方手续费'},
                {field: 'bid_fee_rate', title: '买方费率'},
                {field: 'bid_fee', title: '买方手续费'},
                
                {field: 'create_time', width: 280, title: '成交时间', templet: function(d){
                    return utils.format_timestamp(d.create_time*1000);
                }}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            skin: 'line'
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            // layer.alert(result, {
            //     title: '最终的搜索信息'
            // });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });

        // 监听添加操作
        $(".data-add-btn").on("click", function () {

            
            return false;
        });

        // 监听删除操作
        $(".data-delete-btn").on("click", function () {
            var checkStatus = table.checkStatus('currentTableId')
                , data = checkStatus.data;
            layer.alert(JSON.stringify(data));
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {

                
                return false;
            } else if (obj.event === 'delete') {
                layer.confirm('真的删除行么', function (index) {
                    obj.del();
                    layer.close(index);
                });
            }
        });

        form.val("searchForm", JSON.parse({% .search | json %}));
        form.render();
    });
</script>

{% include "iframe_footer" %}